<#assign base=request.contextPath />
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<title></title>
		<link rel="stylesheet" href="${base}/css/bootstrap.min.css" />
		<script type="text/javascript" src="${base}/js/jquery-1.12.0.min.js"></script>
		<link rel="stylesheet" href="${base}/css/common.css" />
		<script type="text/javascript" src="${base}/js/common.js" ></script>
	</head>
	<body>
		<div class="container-fluid">
			<select id="selectgroup" class="form-control">
			<option>......</option>
				<#list groups as item>
					
					<option value="${item.id}">${item.name}</option>
				</#list>
			</select>
			<ul class="group_list">
				<li id="doctor">
					<span class="key">负责医生：</span>
					<span class="value">
					</span>
				</li>
				<li id="pharmacist"> 
					<span class="key">负责药师：</span>
					<span class="value">

					</span>
				</li>
				<li id="assitant">
					<span class="key">负责助手：</span>
					<span class="value">

					</span>
				</li>
				<li id="memsnum" >
					<span class="key">组员数量：</span>
					<span class="value">
					</span>
				</li>
			</ul>
			<div class="page-header no_border_top">
				<h1>小组介绍</h1>
			</div>
			<p class="group_intro">
			</p>
			<div class="form-group login_reg_btn">
				<button id="submit" class="btn btn-primary">退出组</button>
			</div>
			
		</div>
		<script>
			var group = 0;
			
			
			$("#submit").on("click",function(){
				if($("#selectgroup").prop("selectedIndex")==0) return;
				var url = "exist/"+group 
				$.get(url,{},function(data){
				var res = jQuery.parseJSON(data);
				if(res.status == undefined) {
				
					alert("退组成功" );
					window.location.reload();
				}else alert( "退组失败")
				})
			
			
			} );
			
			
			
			
			$("#selectgroup").change(function(){
				if($(this).prop("selectedIndex")!=0){
					group=$(this).val() ;
	
					$.get("detail/"+group,{},function(result){
					
						$(".group_intro,#doctor .value,#assitant .value,#pharmacist .value,#memnums .value").empty();
						$.each(result.doctors,function(index,obj){

							$("#doctor .value").append("<span>"+obj.name+"</span>");
						});
						$.each(result.assitants,function(index,obj){
							$("#assitant .value").append("<span>"+obj.name+"</span>");
						});
						$.each(result.pharmacists,function(index,obj){
							$("#pharmacist .value").append("<span>"+obj.name+"</span>");
						});
						
						$("#memsnum  .value").html(result.memsnum );
						
						$(".group_intro").html(result.group.description);
					});
					
				}else{
					group=0;
					$(".group_intro,#doctor .value,#assitant .value,#pharmacist .value,#memnums .value").empty();
					
				}
			});
			
			
		</script>
	</body>
</html>
